//系统方法输出列表
package com.xxz.course;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.app.ListActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class MyListActivity extends ListActivity  {
    private static final String TAG ="list";
    Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        handler = new Handler(Looper.myLooper()) {//匿名类定义对象
            @Override
            public void handleMessage(@NonNull Message msg) {
                if (msg.what == 5) {
                   List<String> list2 = (List<String>) msg.obj;
                   ListAdapter adapter = new ArrayAdapter<String>(MyListActivity.this, android.R.layout.simple_list_item_1,list2);
                   setListAdapter(adapter);
                }
                super.handleMessage(msg);
            }
        };//方法重写
        MyTask mytask = new MyTask();//自建类
        mytask.setHandler(handler);

        Thread t = new Thread(mytask);
        t.start();
    }


}